package com.mbti.youmore.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mbti.youmore.entity.Business;
import com.mbti.youmore.service.BusinessService;
import com.mbti.youmore.mapper.BusinessMapper;
import jakarta.validation.constraints.Null;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author Guqier
* @description 针对表【t_business】的数据库操作Service实现
* @createDate 2024-05-08 20:30:44
*/
@Service
public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
    implements BusinessService{
    @Autowired
    private BusinessMapper businessMapper;// 使用Spring自动注入工具类
    @Override
    public int saveBusiness(Business business){
        int userid=business.getUserId();
        String name=business.getName();
        String phone = business.getPhone();
        String CardL = business.getIdCardL();
        String CardR = business.getIdCardL();
        int ispass = business.getIsPass();
        int count=businessMapper.updateByUserId(userid,name,phone,CardL,CardR,ispass);
        return count;
    }
    /**
     * 判断用户是不是商家
     *
     * @param userId 用户id
     * @return 判断用户是不是商家的boolean值
     */
    @Override
    public int isBusiness(int userId) {
        int result=0;
        Business business=businessMapper.selectByUserId(userId);
        if(business!=null) {
            result=business.getIsPass();
            return  result;
        }else {
            return 0;
        }
    }
}




